# eccentric_chuck.py

from __future__ import division

from ot_simulator.component import component

class eccentric_chuck(component.component):
    '''This chuck cuts an ellipse onto the work.
    
    The chuck spindle describes a circle twice as the chuck turns through one
    revolution.  The circle has a diameter of ``e`` centered at ``(e/2, 0)``.

    ===============  ==========================
     Input setting   
    ===============  ==========================
    x_offset         defaults to 0
    y_offset         defaults to 0
    z_offset         defaults to 0
    nosewheel_index  degrees, defaults to 0
    ===============  ==========================

    ===============  ==========================
    Output setting
    ===============  ==========================
    <none>
    ===============  ==========================
    '''
    input_parameters = ('x_offset', 'y_offset', 'z_offset', 'nosewheel_index')

    def get_transform(self, params, transform_in):
        x_offset = self.get_param(params, 'x_offset', 0.0)
        y_offset = self.get_param(params, 'y_offset', 0.0)
        z_offset = self.get_param(params, 'z_offset', 0.0)
        transform_out = transform_in.move(x=x_offset, y=y_offset, z=z_offset)
        nw_index = self.get_param(params, 'nosewheel_index', 0)
        if nw_index:
            transform_out = transform_out.rotate_z(nw_index)
        return transform_out


def test():
    import doctest
    import sys
    sys.exit(doctest.testmod()[0])

if __name__ == "__main__":
    test()
